package cn.com.homeyoda.aimate.aihealth.ui.activity;

import android.os.Bundle;
import android.view.View;

import androidx.lifecycle.ViewModelProviders;

import com.afollestad.materialdialogs.MaterialDialog;
import cn.com.homeyoda.aimate.aihealth.BR;
import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.app.AppViewModelFactory;
import cn.com.homeyoda.aimate.aihealth.base.BaseActivity;
import cn.com.homeyoda.aimate.aihealth.base.BaseViewModel;
import cn.com.homeyoda.aimate.aihealth.data.Repository;
import cn.com.homeyoda.aimate.aihealth.databinding.ActivityActivityDetailBinding;
import com.makeramen.roundedimageview.RoundedImageView;

public class ActivityDetailActivity extends BaseActivity<ActivityActivityDetailBinding, BaseViewModel<Repository>> implements View.OnClickListener {


    @Override
    public BaseViewModel<Repository> initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(BaseViewModel.class);
    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_activity_detail;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        binding.ivBack.setOnClickListener(this);
        binding.ivRegisterNow.setOnClickListener(this);
    }


    @Override
    public void initViewObservable() {
        super.initViewObservable();
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.iv_back) {
            finish();
        } else if (id == R.id.iv_register_now) {
            showDialog();
        }
    }

    private void showDialog() {
        MaterialDialog dialog = new MaterialDialog.Builder(this)
                .customView(R.layout.dialog_feedback, false)
                .show();
//        RoundedImageView imageView = dialog.getView().findViewById(R.id.image);
//        imageView.setImageResource(R.mipmap.img_register);
        dialog.getView().setOnClickListener(v -> dialog.dismiss());
        if (dialog.getWindow() != null) {
            dialog.getWindow().setLayout(550, 581);
            dialog.getWindow().setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(0));
        }
    }

}